package view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JWindow;

public class LivrariaSplash extends JWindow {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1708454503862738643L;

	public LivrariaSplash() {
		load();
	}

	private void load() {

		Image image = null;
		try {
			// Read from a file
			image = ImageIO.read(getClass().getClassLoader().getResourceAsStream("img/LivrariaTacla3.jpg"));
			//image = ImageIO.read(getClass().getClassLoader().getResourceAsStream("img/LivrariaTacla.jpg"));
			
			JLabel label = new JLabel(new ImageIcon(image));
			getContentPane().setLayout(new BorderLayout());
			getContentPane().add(label, BorderLayout.CENTER);
			pack();
			setVisible(true);

			/*
			 * Place in the center
			 */

			Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();

			int iW = image.getWidth(this);
			int iH = image.getHeight(this);

			setLocation((int) (dimension.getWidth() / 2 - iW / 2),
					(int) (dimension.getHeight() / 2 - iH / 2));

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
